<!DOCTYPE html>
<html style="height: 100%">
<head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8">
    <title> {% if order.is_card %}卡券 {% endif %}{% if order.is_active %}激活{% endif %}销售订单打印</title>
    <link rel="shortcut icon" href="/web/static/src/img/favicon.ico" type="image/x-icon">
    <link rel="stylesheet" href="/web/static/src/css/full.css">
    <link rel="stylesheet" href="/web/static/lib/fontawesome/css/font-awesome.css">
    <link rel="stylesheet" href="/web/static/lib/bootstrap/css/bootstrap.css">
    <link rel="stylesheet" href="/web/static/src/css/base.css">

    <script language="javascript" src="/lodop/static/lib/lodop6/LodopFuncs.js"></script>
    <script language="javascript" src="/lodop/static/src/js/mathlibrary.js"></script>

    <style type="text/css" id="style">
        body{padding: 10px; font-size: 10pt}
        @media print
        {
            .print-hide {display:none}
        }
        .td_inline {
            display:block;
            overflow:hidden;
            white-space:nowrap;
            text-overflow:ellipsis;
            width: 370pt;
        }

        .nowrap{
            white-space:nowrap;
        }
        /*.table td.noborder{*/
            /*border-top: 0px;*/
        /*}*/
        .table thead tr td{font-weight: bold; font-size: 11pt}

        h4{margin: 0px;  padding: 0px;font-size: 14pt}
        h5{
            font-size:11pt; font-family:'黑体'; font-weight: bold; margin: 0px;  padding: 0px;
        }
        div{font-size: 10pt}

        span.foot_sign{border-bottom: 1px solid #ddd}

        .table tbody tr td{border-top: 1px solid #ddd;}
        .table tbody tr:last-child td{border-top: 1px solid #fff; padding: 0px}
        .table tbody tr.memo td {padding:0px; border-top:0px}

        td{font-size:10pt}

        .font-middle{
            font-size: 12pt;
        }


        .page_head{
            padding-bottom: 20px;
        }

        .underline{text-decoration: underline;}
    </style>
</head>
<body>
<object  id="LODOP_OB" classid="clsid:2105C259-1E0C-4534-8141-A753534CB4CA" width=0 height=0>
    <embed id="LODOP_EM" type="application/x-print-lodop" width=0 height=0></embed>
</object>
<div class="controls controls-row print-hide">
    <script>
        function CheckIsInstall() {
            try{
                window.LODOP = getLodop(document.getElementById('LODOP_OB'),document.getElementById('LODOP_EM'));
                //if ((LODOP!=null)&&(typeof(LODOP.VERSION)!="undefined")) alert("本机已成功安装过Lodop控件!\n  版本号:"+LODOP.VERSION);
                return true;
            }catch(err){
                //alert("Error:本机打印控件未安装或需要升级!");
            }
        };
        //CheckIsInstall();

        function print_preview(){
            if (!LODOP.VERSION) return;
            LODOP.PRINT_INIT("${orderHeader.orderName}");
            LODOP.SET_PRINT_PAGESIZE(0, 2110, 1400, "2410x1400");

            var strStyle = "<style>" + document.getElementById("style").innerHTML + "</style>";
            LODOP.ADD_PRINT_TABLE(100,"10","100%",380,strStyle + document.getElementById("div-body").innerHTML);
            LODOP.SET_PRINT_STYLEA(0,"Vorient",3);
            LODOP.ADD_PRINT_HTM(0,"10","100%",109, strStyle + document.getElementById("div-header").innerHTML);
            LODOP.SET_PRINT_STYLEA(0,"ItemType",1);
            LODOP.SET_PRINT_STYLEA(0,"LinkedItem",1);
            //LODOP.ADD_PRINT_HTM(430,10,"90%",150, strStyle + document.getElementById("div-memo").innerHTML);
            //LODOP.SET_PRINT_STYLEA(0,"ItemType",1);
            //LODOP.SET_PRINT_STYLEA(0,"LinkedItem",1);
            LODOP.ADD_PRINT_TEXT(475,40,"90%",50,  "业务:{{ order.user_id.name }}　　主管:　　　　　　财务:　　　　　　采购:　　　　　　仓库:　　　　　　");
            LODOP.SET_PRINT_STYLEA(0,"ItemType",1);
            LODOP.SET_PRINT_STYLEA(0,"FontSize",9)
            LODOP.ADD_PRINT_TEXT(475,690,135,20,"第#页/共&页");
            LODOP.SET_PRINT_STYLEA(0,"ItemType",2);
            //LODOP.SET_PRINT_STYLEA(0,"LinkedItem",1);
            LODOP.ADD_PRINT_BARCODE(22,560,220,24,"128Auto","{{ order.name }}");
            LODOP.SET_PRINT_STYLEA(0,"ShowBarText",0);
            //LODOP.SET_PRINT_STYLEA(0,"Angle",90);


            LODOP.PREVIEW();

        }
        window.onload = function(){
            var xiaoxie = document.getElementById('spanGrandTotal').innerHTML;
            var daxie = cmycurd(xiaoxie);
            document.getElementById('spanGrandTotal').innerHTML = xiaoxie + " (" + daxie + ")";
        }
    </script>
    {% if options.priceHide %}
        <a href="?options={&quot;priceHide&quot;:0}" class="btn btn-primary">显示价格</a>
    {% else %}
        <a href="?options={&quot;priceHide&quot;:1}" class="btn btn-primary">隐藏价格</a>
    {% endif %}
    <a href="javascript:if (CheckIsInstall()){print_preview()}" class="btn btn-primary">联单打印预览</a>
    注: 点击按钮打印联单，打印A4纸按Ctrl+P键，或者菜单上面选择文件->打印，文件->页面设置里面可以去除页眉页脚
</div>
<div id="div-header">
    <table border="0" cellSpacing="0" cellPadding="0" width="100%">
        <tbody>
            <tr>
                <td colspan="3" align="center">
                    <h4 class="page_head">{{ order.company_id.name }}
                        {% if order.is_return %}
                            退货单
                        {% else %}
                            {% if order.is_card %}卡券{% endif %}{% if order.is_active %}激活{% endif %}{% if order.state in ['draft','sent'] %}报价单{% else %}销售订单{% endif %}
                        {% endif %}
                    </h4>
                </td>
            </tr>
            <tr>
                <td width="40%">客户:
                    {% if order.partner_id.is_company %}
                        {{ order.partner_id.name|default('', True) }}
                    {% else %}
                        {{ order.partner_id.parent_id.name|default('', True) }}
                    {% endif %}

                </td>
                <td width="33%">联系人:
                    {% if order.partner_id.is_company %}
                        {{ order.partner_id.principal|default('', True) }}
                    {% else %}
                        {{ order.partner_id.name|default('', True) }}
                    {% endif %}
                </td>
                <td><h5>　 编号: {{ order.name }}</h5></td>
            </tr>
            <tr>
                <td>地址:{{ order.partner_shipping_id.state_id.name|default('', True) }}
                    {{ order.partner_shipping_id.city|default('', True) }}
                    {{ order.partner_shipping_id.county|default('', True) }}
                    {% if order.freight_type == 'freight_collect' %}
                    (运费到付)
                    {% endif %}
                    {% if order.customer_pick_up %}
                    (客户自提)
                    {% endif %}

                </td>
                <td>手机: {{ order.partner_shipping_id.mobile|default('　　　　　　', True) }}
                    电话: {{ order.partner_shipping_id.phone|default('　　　　　　', True) }}</td>
                <td>　　下单日期: {{ order.date_order|strftime('%Y-%m-%d') }}
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    　　{{ order.partner_shipping_id.street|default('', True) }}
                    {% if order.partner_shipping_id.zip %}
                        , 邮编:{{ order.partner_shipping_id.zip|default('', True) }}
                    {% endif %}
                </td>
                <td>
                    {% if order.is_return %}
                    预计退货时间:
                    {% else %}
                    预计发货时间:
                    {% endif %}
                    {{ order.estimated_delivery_time|default('', True) }}
                </td>
            </tr>
        </tbody>
    </table>
</div>


<div id="div-body">
    <table class="table table-striped" width="100%">
        <thead>
            <tr>
                <td width="15">#</td>
                <td>产品名称</td>
                <td class="nowrap"></td>
                <td class="nowrap"></td>
                {% if not options.priceHide %}
                <td class="nowrap" style="text-align: right;">单价</td>
                {% endif %}
                <td class="nowrap" style="text-align: right;">数量</td>
                {% if not options.priceHide %}
                <td class="nowrap" style="text-align: right;">小计</td>
                {% endif %}
            </tr>
        </thead>
        <tbody>
            {% for line in order.order_line %}
            <tr>
                <td>{{loop.index}}</td>
                <td colspan="3" class="">
                        <span>{{ line.name }}</span>
                </td>
                {% if not options.priceHide %}
                <td style="text-align: right;">{{ line.price_unit }}</td>
                {% endif %}
                <td style="text-align: right;">{{ line.product_uom_qty|int() }} {% if line.product_uos %}({{ line.product_uos.name }}){% endif %}</td>
                {% if not options.priceHide %}
                <td style="text-align: right;">￥{{ line.price_unit * line.product_uom_qty }}</td>
                {% endif %}
            </tr>
				{% for order_card in order.sale_order_id %}
						{% if order_card.product_id.id==line.product_id.id or order_card.product_id.act_id.id==line.product_id.id %}
						<tr>
							<td></td>
							<td style="text-align: left;" colspan="3">
							券号:{{order_card.starting_number.code}}{% if order_card.continue_number!=1 %}~{{order_card.ending_number}}({{order_card.continue_number}}张){% else %} ({{order_card.continue_number}}张){% endif %}
							</td>
							<td style="text-align: left;"> </td>
							<td style="text-align: left;"> </td>
							<td style="text-align: left;"> </td>
						</tr>
						{% endif %} 
				{% endfor %}
            {% endfor %}
            <tr>
                <td></td>
                <td>
                </td>
                <td colspan="5" style="text-align: right;border-top: 1px solid #ddd;">
                    {% if not options.priceHide %}
                    合计：￥<span id="spanGrandTotal">{{ order.amount_total }}</span>
                    {% endif %}
                </td>
            </tr>

            {% if order.note %}
            {% for line in note_lines %}
            <tr class="memo">
                <td colspan="7">
                    {% if loop.first %}备注:{% endif %}
                    {{ line }}
                </td>
            </tr>
            {% endfor %}
            {% endif %}
        </tbody>
    </table>
</div> 
 
 
<div id="div-foot">
    业务：<span class="foot_sign">{{ order.user_id.name|default("　　　　") }}　　</span>
    主管:<span class="foot_sign">　　　　　　</span>
    财务：<span class="foot_sign">　　　　　　</span>
    采购：<span class="foot_sign">　　　　　　</span>
    仓库：<span class="foot_sign">　　　　　　</span>
</div>

</body>
</html>
